class Solution {
    public static void main(String[] args) {
        float sum = (float) 1.2;
        System.out.println("%f");
    }

    static int[] dig1;
    static int[] dig2;
    static int[] dig3;
    static boolean falg;

    public boolean isValidSudoku(char[][] board) {
        dig1 = new int[10];
        dig2 = new int[10];
        dig3 = new int[10];
        falg = true;
        dfs(board, 0);
        return falg;
    }

    static void dfs(char[][] board, int row) {
        if (falg == false) {
            return;
        }
        if (row % 3 == 0) {
            dig1 = new int[10];
            dig2 = new int[10];
            dig3 = new int[10];
        }
        if(row == 9){
            return;
        }
        int index = 0;
        for (int i = 0; i < 9; i++) {
           
            if (i % 3 == 0) {
                index++;
            }
            if (index == 0) {
                if (dig1[i] == 0 && board[row][i] != '.') {
                    dig1[(int) board[row][i] - '0']++;
                } else if(dig1[i] != 0 && board[row][i] != '.') {
                    falg = false;
                    break;
                }
            }
            if (index == 1) {
                if (dig2[i] == 0 && board[row][i] != '.') {
                    dig2[(int) board[row][i] - '0']++;
                } else if(dig3[i] != 0 && board[row][i] != '.') {
                    falg = false;
                    break;
                }
            }
            if (index == 2) {
                if (dig3[i] == 0 && board[row][i] != '.') {
                    dig3[(int) board[row][i] - '0']++;
                } else if(dig3[i] != 0 && board[row][i] != '.') {
                    falg = false;
                    break;
                }
            }

        }
        dfs(board, row + 1);

    }
}